﻿<extend name="./_base"/>
<block name="css">

</block>
<block name="content">

        <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 权限管理 <span
                class="c-gray en">&gt;</span> 节点管理 <a class="btn btn-success radius r"
                                                      style="line-height:1.6em;margin-top:3px"
                                                      href="javascript:location.replace(location.href);" title="刷新"><i
                class="Hui-iconfont">&#xe68f;</i></a></nav>
        <div class="page-container">
            <div class="text-c">
                <form class="Huiform" method="post" action="" target="_self">
                    <input type="text" class="input-text" style="width:250px" placeholder="权限名称" name="search">
                    <button type="submit" class="btn btn-success"><i class="Hui-iconfont">&#xe665;</i> 搜权限节点</button>
                </form>
            </div>

            <div class="cl pd-5 bg-1 bk-gray mt-20"><span class="l"><a href="javascript:;" onclick="datadel()"
                                                                       class="btn btn-danger radius"><i
                    class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a href="javascript:;"
                                                                  onclick="add()"
                                                                  class="btn btn-primary radius"><i
                    class="Hui-iconfont">&#xe600;</i> 添加权限节点</a></span></div>
            <table id="rule-list" class="table table-border table-bordered table-bg">
                <thead>
                <tr>
                    <th scope="col" colspan="7">权限节点</th>
                </tr>
                <tr class="text-c">
                    <th width="25"><input type="checkbox" name="" value=""></th>
                    <th width="40">ID</th>
                    <th width="200">权限名称</th>
                    <th>URL规则</th>
                    <th>type</th>
                    <th>表达式</th>
                    <th>状态</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
</block>

<block name="script">
    <script src="__PUBLIC__/Lib/datatables/js/jquery.dataTables.js"></script>
    <script type="text/javascript">

        scope.status_url='{:U(ruleStatus)}';
        $('#rule-list').dataTable({
            order: [[1, 'desc']],
            processing: true,
            serverSide: true,
            ajax: {
                url: ''
            },
            columns: [
                {
                    data: 'id',
                    render: function (data) {
                        return '<input type="checkbox" name="id" value="' + data + '">'
                    },
                    className: 'text-c',
                    orderable: false
                },
                {
                    data: 'id',
                    className: 'text-c',
                },
                {data: 'title'},
                {data: 'name'},
                {data: 'type'},
                {data: 'condition'},
                {
                    data: 'status',
                    render: function (data, type, row, meta) {
                        var render;
                        switch (parseInt(data)) {
                            case 0:
                                render = '<label class="label radius">已禁用</label>';
                                break;
                            case 1:
                                render = '<label class="label label-success radius">已启用</label>';
                                break;
                            default:
                                render = '<label class="label label-danger radius">未知状态</label>';
                                break;
                        }
                        return render;
                    },
                    className: 'text-c'
                },
                {
                    render: function (data, type, row, meta) {
                        var render;
                        switch (parseInt(row.status)) {
                            case -1:
                                render = '<a href="javascript:void(0);" onclick="start(' + row.id + ')" title="启用"><i class="Hui-iconfont Hui-iconfont-shangjia"></i></a>';
                                break;
                            case 0:
                                render = '<a href="javascript:void(0);" onclick="start(' + row.id + ')" title="启用"><i class="Hui-iconfont Hui-iconfont-shangjia"></i></a>';
                                render += '<a class="ml-5" href="javascript:void(0);" onclick="del(' + row.id + ')" title="删除"><i class="Hui-iconfont Hui-iconfont-del3"></i></a>';
                                break;
                            case 1:
                                render = '<a href="javascript:void(0);" onclick="stop(' + row.id + ')" title="停用"><i class="Hui-iconfont Hui-iconfont-xiajia"></i></a>';
                                break;
                        }
                        render += '<a class="ml-5" href="javascript:void(0);" onclick="edit(' + row.id + ')" title="编辑"><i class="Hui-iconfont Hui-iconfont-edit"></i></a>'

                        return render;

                    },
                    "orderable": false,
                    "className": "text-c"
                }
            ]

        })

        /*管理员-权限组-添加*/
        function add() {
            layer_show('添加规则', '{:U(ruleEdit)}', 480, 300);
        }
        /*管理员-权限组-编辑*/
        function edit(id) {
            layer_show('修改规则', '{:U(ruleEdit)}?id=' + id, 480, 300);
        }

        function del(id) {
            status(id, 'remove')
        }
        //启用
        function start(id) {
            status(id, 'start')
        }
        //停用
        function stop(id) {
            status(id, 'stop')
        }


    </script>

</block>
